package test.unit 
{
	import net.digitalprimates.fluint.sequence.SequenceWaiter;
	import net.digitalprimates.fluint.sequence.SequenceRunner;
	import mx.utils.StringUtil;
	import com.zanshine.benchmark.api.BenchmarkSuite;
	
	import flash.events.Event;
	
	import net.digitalprimates.fluint.tests.TestCase;
	
	import test.mock.BenchmarkableMock;

	public class BenchmarkCaseTest extends TestCase
	{
		private var benchCase:BenchmarkableMock;
		private var benchSuite:BenchmarkSuite;
		
		override protected function setUp():void
		{
			benchCase = new BenchmarkableMock;
			benchSuite = new BenchmarkSuite;
		}
				
		public function testAPICallOrdering():void
		{
			benchSuite.addBenchmark(benchCase);
			var seq:SequenceRunner = new SequenceRunner(this);
			
			seq.addStep(new SequenceWaiter(benchCase, BenchmarkableMock.PREPARE, 50, prepareTimeOut));
			seq.addStep(new SequenceWaiter(benchCase, BenchmarkableMock.SET_UP, 50, firstSetupTimeOut));
			seq.addStep(new SequenceWaiter(benchCase, BenchmarkableMock.METHOD, 50, firstMethodTimeOut));
			seq.addStep(new SequenceWaiter(benchCase, BenchmarkableMock.TEAR_DOWN, 50, firstTearDownTimeOut));
			seq.addStep(new SequenceWaiter(benchCase, BenchmarkableMock.SET_UP, 50, secondSetupTimeOut));
			seq.addStep(new SequenceWaiter(benchCase, BenchmarkableMock.METHOD, 50, secondMethodTimeOut));
			seq.addStep(new SequenceWaiter(benchCase, BenchmarkableMock.TEAR_DOWN, 50, secondTearDownTimeOut));
			seq.addStep(new SequenceWaiter(benchCase, BenchmarkableMock.CLEAN, 50, cleanTimeOut));
			seq.run();
			benchSuite.run();
		}

		private function prepareTimeOut(arg:*):void
		{
			fail('prepare() failed');
		}
		
		private function firstSetupTimeOut(arg:*):void
		{
			fail('first setup() failed');
		}
		
		private function firstMethodTimeOut(arg:*):void
		{
			fail('first method() failed');
		}
		
		private function firstTearDownTimeOut(arg:*):void
		{
			fail('first tearDown() failed');
		}
		
		private function secondSetupTimeOut(arg:*):void
		{
			fail('second setup() failed');
		}
		
		private function secondMethodTimeOut(arg:*):void
		{
			fail('second method() failed');
		}
		
		private function secondTearDownTimeOut(arg:*):void
		{
			fail('second tearDown() failed');
		}
		
		private function cleanTimeOut(arg:*):void
		{
			fail('clean() failed');
		}
	}
}